﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyKho.Server;

namespace QuanLyKho.Server
{
    public partial class PhieuXuatThuoc
    {
        public string NgayXuatDDMMYYYY
        {
            get
            {
                return NgayXuat.ToString("dd/MM/yyyy hh:mm:ss");
            }
        }

        public decimal TongTien
        {
            get
            {
                if (IdPhieuXuat != 0)
                {
                    using (QuanLyKhoEntities entities = new QuanLyKhoEntities(QuanLyKhoServerGlobal.ConnectionString))
                    {
                        List<PhieuXuatThuocChiTiet> list = entities.PhieuXuatThuocChiTiets.Where(u => u.IdPhieuXuat == IdPhieuXuat).ToList();
                        if(list.Count > 0)
                        {
                            return list.Sum(u => u.GiaXuat * u.SoLuong);
                        }
                        return 0;
                    }
                }
                return 0;
            }
        }
    }
}
